using System;
using System.ComponentModel;
using System.Transactions;

using SIS.ENT;
using SIS.DAL;


namespace SIS.BLL {

/// <summary>
/// The SchoolContactTableManager class is responsible for managing BO.SchoolContactTable objects in the system.
/// </summary>
[DataObjectAttribute()]
public class SchoolContactTableManager
  {

#region "Public Methods"

/// <summary>
/// Gets a list with all SchoolContactTable objects in the database.
/// </summary>
/// <returns>A list with all SchoolContactTable from the database when the database contains any, or null otherwise.</returns>
[DataObjectMethod(DataObjectMethodType.Select, true)]
public static SchoolContactTableList GetList(){
return SchoolContactTableDB.GetList();
}

/// <summary>
/// Gets a single SchoolContactTable from the database without its data.
/// </summary>
/// <param name="schoolContactKey">The SchoolContactKey of the SchoolContactTable in the database.</param>
/// <returns>A SchoolContactTable object when the SchoolContactKey exists in the database, or <see langword="null"/> otherwise.</returns>
[DataObjectMethod(DataObjectMethodType.Select, false)]
public static SchoolContactTable GetItem(int schoolContactKey){
return GetItem(schoolContactKey, false);
}

/// <summary>
/// Gets a single SchoolContactTable from the database.
/// </summary>
/// <param name="schoolContactKey">The SchoolContactKey of the SchoolContactTable in the database.</param>
/// <param name="getSchoolContactTableRecords">Determines whether to load all associated SchoolContactTable records as well.</param>
/// <returns>
/// A SchoolContactTable object when the SchoolContactKey exists in the database, or <see langword="null"/> otherwise.
/// </returns>
[DataObjectMethod(DataObjectMethodType.Select, false)]
public static SchoolContactTable GetItem(int schoolContactKey, bool getSchoolContactTableRecords){
SchoolContactTable mySchoolContactTable = SchoolContactTableDB.GetItem(schoolContactKey);
return mySchoolContactTable;
}

/// <summary>
/// Saves a SchoolContactTable in the database.
/// </summary>
/// <param name="mySchoolContactTable">The SchoolContactTable instance to save.</param>
/// <returns>The new SchoolContactKey if the SchoolContactTable is new in the database or the existing SchoolContactKey when an item was updated.</returns>
[DataObjectMethod(DataObjectMethodType.Update, true)]
public static int Save(SchoolContactTable mySchoolContactTable){
using (TransactionScope myTransactionScope = new TransactionScope()){
int schoolContactTableSchoolContactKey = SchoolContactTableDB.Save(mySchoolContactTable);

//  Assign the SchoolContactTable its new (or existing SchoolContactKey).
mySchoolContactTable.SchoolContactKey = schoolContactTableSchoolContactKey;

myTransactionScope.Complete();

return schoolContactTableSchoolContactKey;
}
}

/// <summary>
/// Deletes a SchoolContactTable from the database.
/// </summary>
/// <param name="mySchoolContactTable">The SchoolContactTable instance to delete.</param>
/// <returns>Returns true when the object was deleted successfully, or false otherwise.</returns>
[DataObjectMethod(DataObjectMethodType.Delete, true)]
public static bool Delete(SchoolContactTable mySchoolContactTable){
return SchoolContactTableDB.Delete(mySchoolContactTable.SchoolContactKey);
}

#endregion

}

}
